var arr = [5, 4, 3, 2, 1];
document.write('<center>原数组[5, 4, 3, 2, 1]<br>以下为过程<br></center>')

for (var i = 0; i < 5; i++) {
    for (var j = 0; j < arr.length - i - 1; j++) {
        document.write('<center>' + arr + '<br></center>');
        if (arr[j] > arr[j + 1]) {
            temp = arr[j + 1]
            arr[j + 1] = arr[j]
            arr[j] = temp
        }
    }
}
